package com.hunttown.mes.dao;

import com.hunttown.common.dao.base.BaseDao;
import com.hunttown.common.domain.Query;
import com.hunttown.mes.domain.TransportUserLoginLog;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.List;

/**
 * created by wangjunfu on 2021-02-24 16:00:14
 */
public class TransportUserLoginLogDao extends BaseDao {
    private static final Logger logger = LoggerFactory.getLogger(TransportUserLoginLogDao.class);

    public TransportUserLoginLog insert(final TransportUserLoginLog transportUserLoginLog) {
        insert("TransportUserLoginLog.insert", transportUserLoginLog);
        return transportUserLoginLog;
    }

    public Boolean updateInfoById(final TransportUserLoginLog transportUserLoginLog) {
        return update("TransportUserLoginLog.updateInfoById", transportUserLoginLog) > 0;
    }

    public Boolean updateInfoByQuery(final Query query) {
        return update("TransportUserLoginLog.updateInfoByQuery", query) > 0;
    }

    public TransportUserLoginLog selectById(final Integer id, final Integer entId) {
        Query query = Query.noPage();
        query.put("id", id);
        query.put("entId", entId);
        return queryForObject("TransportUserLoginLog.selectById", query);
    }

    public List<TransportUserLoginLog> selectByQuery(final Query query) {
        return queryForList("TransportUserLoginLog.selectByQuery", query);
    }

    public Long countByQuery(final Query query) {
        return queryForObject("TransportUserLoginLog.countByQuery", query);
    }

    public Boolean deleteById(final Integer id, final Integer entId) {
        TransportUserLoginLog transportUserLoginLog = new TransportUserLoginLog();
        //transportUserLoginLog.setDeleteFlag(1);
        transportUserLoginLog.setId(id);
        transportUserLoginLog.setEntId(entId);

        return update("TransportUserLoginLog.updateInfoById", transportUserLoginLog) > 0;
    }

    //物理删除不可恢复，慎用！
    public Boolean deleteByIdForPhysical(final Integer id) {
        Query query = Query.noPage();
        query.put("id", id);
        return delete("TransportUserLoginLog.deleteById", query) > 0;
    }
}